/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Reporte;

import java.io.File;
import java.util.LinkedList;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JRResultSetDataSource;

/**
 *
 * @author marco
 */
import net.sf.jasperreports.engine.JasperCompileManager;
	import net.sf.jasperreports.engine.JasperFillManager;
	import net.sf.jasperreports.engine.JasperPrint;
	import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
	import net.sf.jasperreports.swing.JRViewer;
import net.sf.jasperreports.view.JasperViewer;
public class Reportes {

    public Reportes(){}
    
    public void mostrarReporteTareasVencidas(java.sql.ResultSet resulset){

    try 
{ 
  
    File archivo  = new File(System.getProperty("user.dir").replace("/dist", "")+"/src/Reporte"+"/prueba1.jasper");
    System.out.println(archivo.getPath());
    if (archivo.exists()){
  
  JasperReport reporte = (JasperReport) JRLoader.loadObject(archivo.getPath()); 
    //JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, new JRBeanCollectionDataSource(a)); 
     JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, new JRResultSetDataSource(resulset) );
      JasperViewer jviewer = new JasperViewer(jasperPrint, false);
            jviewer.setTitle("Reporte");
            jviewer.setVisible(true);
  //  JRExporter exporter = new JRPdfExporter(); 
   // exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    //exporter.setParameter(JRExporterParameter.OUTPUT_FILE, new java.io.File("prueba1enPDf.pdf")); 
    //exporter.exportReport(); 
  //          JRResultSetDataSource(JasperReportsContext jasperReportsContext, java.sql.ResultSet resultSet) 

    }
    else{
    System.out.println("no existe el archivo");}
} 
catch(JRException e) 
{ 
    e.printStackTrace(); 
} 

    
     }
}
